import vue from "@vitejs/plugin-vue";
import eslintPlugin from "vite-plugin-eslint";
import VueDevTools from "vite-plugin-vue-devtools";
import createAutoImport from "./auto-import";
import createSvgIcon from "./svg-icon";
import createCompression from "./compression";
import createSetupExtend from "./setup-extend";
import inject from "@rollup/plugin-inject"; // 使用插件 @rollup/plugin-inject 注入全局 jQuery 效果和webpack.ProvidePlugin中相同
import monacoEditorPlugin from "vite-plugin-monaco-editor";
import vueJsx from "@vitejs/plugin-vue-jsx";
export default function createVitePlugins(viteEnv, isBuild = false) {
    const vitePlugins = [vue(), vueJsx(), VueDevTools()];
    vitePlugins.push(createAutoImport());
    vitePlugins.push(createSetupExtend());
    vitePlugins.push(createSvgIcon(isBuild));
    isBuild && vitePlugins.push(...createCompression(viteEnv));
    vitePlugins.push(
        eslintPlugin({
            include: ["src/**/*.js", "src/**/*.vue", "src/*.js", "src/*.vue"],
        })
    );
    vitePlugins.push(
        inject({
            $: "jquery", // 这里会自动载入 node_modules 中的 jquery jquery全局变量
            jQuery: "jquery",
            "windows.jQuery": "jquery",
        })
    );
    vitePlugins.push(
        monacoEditorPlugin({
            languageWorkers: ["editorWorkerService", "typescript", "json", "html"],
        })
    );

    return vitePlugins;
}
